home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AppsToGo / Kibitz / Sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  2.1 KB  |  109 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:             sound.c
  5. ** Originally from:  SoundCdev by Jeremy Bornstein
  6. ** Modified by:      Eric Soldan
  7. **
  8. ** Copyright © 1990-1992 Apple Computer, Inc.
  9. ** All rights reserved. */
  10.  
  11.  
  12.  
  13. /*****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  18. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  19. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24.  
  25. #ifndef __FILES__
  26. #include <Files.h>
  27. #endif
  28.  
  29. #ifndef __SOUND__
  30. #include <Sound.h>
  31. #endif
  32.  
  33. #ifndef __SOUNDINPUT__
  34. #include <SoundInput.h>
  35. #endif
  36.  
  37. #ifndef __UTILITIES__
  38. #include <Utilities.h>
  39. #endif
  40.  
  41.  
  42.  
  43. /*****************************************************************************/
  44. /*****************************************************************************/
  45.  
  46. #ifdef applec
  47. #pragma segment Sound
  48. #endif
  49.  
  50. /*****************************************************************************/
  51. /*****************************************************************************/
  52.  
  53.  
  54.  
  55. OSErr    RecordSound(FileRecHndl frHndl)
  56. {
  57.     Handle    newSnd, oldSnd;
  58.     OSErr    err;
  59.     Point    corner = {50, 50};
  60.  
  61.     if (!(newSnd = NewHandle(31 * 1024))) return(memFullErr);
  62.  
  63.     err = SndRecord(nil, corner, siBetterQuality, &newSnd);
  64.  
  65.     if (!err) {
  66.         oldSnd = (*frHndl)->doc.sound;
  67.         if (oldSnd) DisposeHandle(oldSnd);
  68.         (*frHndl)->doc.sound = newSnd;
  69.     }
  70.     else DisposeHandle(newSnd);
  71.  
  72.     return(err);
  73. }
  74.  
  75.  
  76.  
  77. /*****************************************************************************/
  78.  
  79.  
  80.  
  81. /* SoundInputAvaliable
  82. **
  83. ** Sound input is avaliable if there's a device registered… */
  84.  
  85. Boolean SoundInputAvaliable(void)
  86. {
  87.     Boolean        siPresent;
  88.     Handle        devIconHandle;
  89.     Str255        devName;
  90.     NumVersion    vers;
  91.     
  92.     siPresent = false;
  93.     
  94.     if (gSystemVersion >= 0x0700) {
  95.         vers = SndSoundManagerVersion();
  96.         if (vers.majorRev > 0) {
  97.             if (SPBGetIndexedDevice(1, devName, &devIconHandle) == noErr) {
  98.                 DisposeHandle(devIconHandle);
  99.                 siPresent = true;
  100.             }
  101.         }
  102.     }
  103.  
  104.     return(siPresent);
  105. }
  106.  
  107.  
  108.  
  109.